package com.jsmile.cloud.tradecenter.cart.repo;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jsmile.cloud.tradecenter.cart.dao.ShoppingCartDao;
import com.jsmile.cloud.tradecenter.cart.model.ShoppingCart;

import lombok.AllArgsConstructor;

@Component
@AllArgsConstructor
@Transactional(readOnly = true)
public class ShoppingCartSearchRepository extends ServiceImpl<ShoppingCartDao, ShoppingCart> {

    public ShoppingCart findByUserIdAndSkuIdAndDeliveryTypeAndTenantIdAndShopId(Long userId, Long skuId, Integer deliveryType, Long tenantId, Long shopId) {
        return this.baseMapper.selectOne(new QueryWrapper<ShoppingCart>().lambda().eq(ShoppingCart::getSkuId, skuId).eq(ShoppingCart::getDeliveryType, deliveryType)
            .eq(ShoppingCart::getTenantId, tenantId).eq(ShoppingCart::getShopId, shopId).eq(ShoppingCart::getUserId, userId));
    }

}
